/**
 * Copyleft (C) 2023-2024 maminjie <canpool@163.com>
 * SPDX-License-Identifier: BSD-3-Clause
 **/
#ifndef QXMATERIALCIRCULARPROGRESS_P_H
#define QXMATERIALCIRCULARPROGRESS_P_H

#include "qxmaterial_global.h"
#include "matcircularprogress.h"
#include <QColor>
#include <QObject>

QX_MATERIAL_BEGIN_NAMESPACE

class MatCircularProgress;
class MatCircularProgressDelegate;

class MatCircularProgressPrivate
{
    Q_DISABLE_COPY(MatCircularProgressPrivate)
    Q_DECLARE_PUBLIC(MatCircularProgress)
public:
    MatCircularProgressPrivate(MatCircularProgress *q);
    ~MatCircularProgressPrivate();

    void init();

    MatCircularProgress *const q_ptr;
    MatCircularProgressDelegate *delegate;
    Material::ProgressType progressType;
    QColor color;
    qreal penWidth;
    int size;
    bool useThemeColors;
};

class MatCircularProgressDelegate : public QObject
{
    Q_OBJECT

    Q_PROPERTY(qreal dashOffset WRITE setDashOffset READ dashOffset)
    Q_PROPERTY(qreal dashLength WRITE setDashLength READ dashLength)
    Q_PROPERTY(int angle WRITE setAngle READ angle)
public:
    MatCircularProgressDelegate(MatCircularProgress *parent);
    ~MatCircularProgressDelegate();

    inline void setDashOffset(qreal offset);
    inline qreal dashOffset() const;

    inline void setDashLength(qreal length);
    inline qreal dashLength() const;

    inline void setAngle(int angle);
    inline int angle() const;
private:
    Q_DISABLE_COPY(MatCircularProgressDelegate)

    MatCircularProgress *const m_progress;
    qreal m_dashOffset;
    qreal m_dashLength;
    int m_angle;
};

inline void MatCircularProgressDelegate::setDashOffset(qreal offset)
{
    m_dashOffset = offset;
    m_progress->update();
}

inline qreal MatCircularProgressDelegate::dashOffset() const
{
    return m_dashOffset;
}

inline void MatCircularProgressDelegate::setDashLength(qreal length)
{
    m_dashLength = length;
    m_progress->update();
}

inline qreal MatCircularProgressDelegate::dashLength() const
{
    return m_dashLength;
}

inline void MatCircularProgressDelegate::setAngle(int angle)
{
    m_angle = angle;
    m_progress->update();
}

inline int MatCircularProgressDelegate::angle() const
{
    return m_angle;
}


QX_MATERIAL_END_NAMESPACE

#endif   // QXMATERIALCIRCULARPROGRESS_P_H
